FROM php:7.2-fpm
MAINTAINER chengang <chengang@zhuge.com>
#设置工作目录
WORKDIR /www

ENV LC_ALL C.UTF-8
ENV WORK  /data
RUN mkdir -p $WORK
COPY composer.phar $WORK
COPY amqp-1.9.3.tgz $WORK
COPY phpredis-5.3.4.tar.gz $WORK

ENV TZ "Asia/Shanghai"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
    && sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
    && sed -i s@/security.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
    && apt-get clean \
    && apt-get update \
    && apt-get install -y \
        libfreetype6-dev \
        libcurl4-gnutls-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        iputils-ping \
        git \
        librabbitmq-dev \
        libmcrypt-dev \
        unzip \
        zip \
        wget \
        vim \
        curl file g++ gcc libc-dev make pkgconf re2c ca-certificates \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install zip \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-install opcache \
    && docker-php-ext-install mysqli \
    && docker-php-ext-install shmop \
    && docker-php-ext-install sysvsem \
    && docker-php-ext-install sockets \
    && docker-php-ext-install bcmath \
    && rm -r /var/lib/apt/lists/*


# 编译安装Redis扩展
RUN cd $WORK && mkdir -p redis && tar -zxvf phpredis-5.3.4.tar.gz -C redis --strip-components=1 && cd redis  \
      && phpize && ./configure && make && make install \
      && docker-php-ext-enable redis

# 安装amqp扩展
RUN  cd $WORK && pecl install amqp-1.9.3.tgz \
    && echo 'extension=amqp.so' >> /usr/local/etc/php/conf.d/docker-php-ext-qmqp.ini


#安装composer
RUN cd $WORK &&  mv composer.phar /usr/local/bin/composer \
    && chmod +x /usr/local/bin/composer \
            # clear
            && php -v \
            && php -m \
            && echo -e "\033[42;37m Build Completed :).\033[0m\n"
